<?php
namespace app\client\controller\game\hall;

class LoginController extends \think\Controller {
  /**
   *  @brief  : 微信登陆
   *  @return : page
   *  @details: http://hh.ct.game654.com/game.hall.login/wchat.html
   *  @details:
   *  @details:
   */
  public function wchatAction() {

    if ($this->request->isGet()) { // 测试
      $data = [
        'dwChannel'    => 43529,//  -- 43529,43556
        'cbPlatformID' => 2,
        'szUserUin'    => 'o-yqAvxS4Shxmfyz3-lcIRettm-g',
        'szOpenID'     => '',
        'szNickName'   => '小鲜肉',
        'cbGender'     => 2,
        'szClientIP'   => '60.177.223.200',
        'szMachineID'  => '',
        'szWXImageURL' => 'http://thirdwx.qlogo.cn/mmopen/vi_32/Q0j4TwGTfTJFFnlJW2Id1zKwKdsIQCa3b4rWW2kjxC1NWHceUr48vtSTW0kjjI3bW9eLb3yXgc9uv1XXDAb5KQ/132',
        'fRadiusN'     => 120.242381,
        'fRadiusS'     => 30.368411,
        'szAddress'    => 'UM::',
        'dwVersion'    => 1012,
      ];
      return $this->fetch('', ['data' => $data]);
    }
    
    if ($this->request->isPost()) {
      $dwChannel    = $this->request->param('dwChannel/d', 0);
      $cbPlatformID = $this->request->param('cbPlatformID/d', 0);
      $szUserUin    = $this->request->param('szUserUin/s', '');
      $szOpenID     = $this->request->param('szOpenID/s', '');
      $szNickName   = $this->request->param('szNickName/s', '');
      $cbGender     = $this->request->param('cbGender/d', 0);
      $szClientIP   = $this->request->param('szClientIP/s', '');
      $szMachineID  = $this->request->param('szMachineID/s', '');
      $szWXImageURL = $this->request->param('szWXImageURL/s', '');
      $fRadiusN     = $this->request->param('fRadiusN/f', 0);
      $fRadiusS     = $this->request->param('fRadiusS/f', 0);
      $szAddress    = $this->request->param('szAddress/s', '');
      $dwVersion    = $this->request->param('dwVersion/d', 0);

      $pdo = table('', 'rydb.accounts')->query("
EXEC RYAccountsDB.[dbo].[GO_EfficacyOtherPlatform]
  @dwChannel    = ?,
  @cbPlatformID = ?,
  @szUserUin    = ?,
  @szOpenID     = ?,
  @szNickName   = ?,
  @cbGender     = ?,
  @szClientIP   = ?,
  @szMachineID  = ?,
  @szWXImageURL = ?,
  @fRadiusN     = ?,
  @fRadiusS     = ?,
  @szAddress    = ?,
  @dwVersion    = ?
", [
  $dwChannel, $cbPlatformID, $szUserUin, $szOpenID, $szNickName, $cbGender, $szClientIP,
  $szMachineID, $szWXImageURL, $fRadiusN, $fRadiusS, $szAddress, $dwVersion], false, true);
      $result = [];
      do {
        $result[] = $pdo->fetchAll(\PDO::FETCH_ASSOC);
      } while ($pdo->nextRowset());

      $retn = $result[0][0];
      if ($retn['dwResult'] != 0) {
        return result([], $retn['dwResult'], $retn['szResult']);
      }

      $retn = [
        'User'  => $result[1][0] ?? [],
        'Kind'  => $result[2] ?? [],
        'Wheel' => [
          'List' => $result[3] ?? [],
          'Info' => $result[4][0] ?? [],
        ],
        'Sign' => [
          'List' => $result[5] ?? [],
          'Info' => $result[6][0] ?? [],
        ],
        'Room' => $result[7] ?? [],
      ];

      return result($retn, 0);
    }
  }
  /**http://hh.ct.game654.com/game.hall.game/enter
   *  @brief  : 游客登陆
   *  @return : JSON
   *  @details: http://hh.ct.game654.com/game.hall.login/guest
   */
  public function guestAction() {
    var_dump(__METHOD__);


  }
}
